import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description: 第九题
 * User: 姚东名
 * Date: 2024-11-16
 * Time: 10:27
 */
public class Demo4 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt(); // 读取数列长度
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt(); // 读取数列元素
        }
        int k = scanner.nextInt(); // 读取整数 k
        scanner.close();

        System.out.println(maxSumOfKElements(n, a, k));
    }

    public static int maxSumOfKElements(int n, int[] a, int k) {
        int maxSum = Integer.MIN_VALUE; // 初始化最大和为最小整数
        for (int p = 0; p <= n - 2 * k + 1; p++) {
            int currentSum = 0;
            for (int i = 0; i < k; i++) {
                currentSum += a[p + 2 * i]; // 计算当前窗口的和
            }
            maxSum = Math.max(maxSum, currentSum); // 更新最大和
        }
        return maxSum;
    }
}
